package edu.gdkm.demo12;

import java.io.*;
import java.util.HashMap;

public class MapTest2 {
    public static void main(String[] args) {
        HashMap<String,Student> hashMap = new HashMap<>();
        try {
            File file = new File("./facebook_number.txt");
            //使用缓存流实现文件的逐行读取
            BufferedReader br=new BufferedReader(new FileReader(file));
            String info;
            while((info=br.readLine())!=null){
                String infos[]=info.split(",");
                Student student= new Student();
                student.setStudentNumber(infos[0]);
                student.setStudentName(infos[1]);
                student.setPhone(infos[2]);
                hashMap.put(student.getStudentNumber(), student);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.out.println("当前学生数量为："+hashMap.size()+"**********************************");
        System.out.println(hashMap.get("22060201264"));
        hashMap.remove("22060201264");
        System.out.println("当前学生数量为："+hashMap.size()+"**********************************");
        for(String key:hashMap.keySet()){
            System.out.println(hashMap.get(key));
        }
    }
}
